package com.toolsder.demo.spring.security.jwt.config;

import com.toolsder.demo.spring.security.jwt.util.SnowFlake;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * created by Qk on 2020/1/28
 * 项目初始化配置
 *
 * @author by 猴子请来的逗比
 */
@Configuration
public class SnowFlakeConfig {

    /**
     * 雪花算法数据中心编号
     */
    @Value("${snowFlake.dataCenterId}")
    private long dataCenterId;
    /**
     * 雪花算法机器编号
     */
    @Value("${snowFlake.machineId}")
    private long machineId;

    /**
     * 返回当前设备的雪花算法
     */
    @Bean(name = "snowFlake")
    public SnowFlake snowFlake() {
        return new SnowFlake(dataCenterId, machineId);
    }

}
